{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "Optimizing the ridge regression parameter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RidgeCV(alphas=array([ 0.1,  0.2,  0.3,  0.4]), cv=None, fit_intercept=True,\n",
       "    gcv_mode=None, normalize=False, scoring=None, store_cv_values=False)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.datasets import make_regression\n",
    "reg_data, reg_target = make_regression(n_samples=100, n_features=2, effective_rank=1, noise=10)\n",
    "\n",
    "from sklearn.linear_model import RidgeCV\n",
    "rcv = RidgeCV(alphas=np.array([.1, .2, .3, .4]))\n",
    "rcv.fit(reg_data, reg_target)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.29999999999999999"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rcv.alpha_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.12"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rcv2 = RidgeCV(alphas=np.array([.08, .09, .1, .11, .12]))\n",
    "rcv2.fit(reg_data, reg_target)\n",
    "rcv2.alpha_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RidgeCV(alphas=array([ 0.01   ,  0.0302 ,  0.05041,  0.07061,  0.09082,  0.11102,\n",
       "        0.13122,  0.15143,  0.17163,  0.19184,  0.21204,  0.23224,\n",
       "        0.25245,  0.27265,  0.29286,  0.31306,  0.33327,  0.35347,\n",
       "        0.37367,  0.39388,  0.41408,  0.43429,  0.45449,  0.47469,\n",
       "        0.4949 ,  0.5151 ...3837,\n",
       "        0.85857,  0.87878,  0.89898,  0.91918,  0.93939,  0.95959,\n",
       "        0.9798 ,  1.     ]),\n",
       "    cv=None, fit_intercept=True, gcv_mode=None, normalize=False,\n",
       "    scoring=None, store_cv_values=True)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "alphas_to_test = np.linspace(0.01, 1)\n",
    "rcv3 = RidgeCV(alphas=alphas_to_test, store_cv_values=True)\n",
    "rcv3.fit(reg_data, reg_target)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(100L, 50L)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rcv3.cv_values_.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.29285714285714287"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "smallest_idx = rcv3.cv_values_.mean(axis=0).argmin()\n",
    "alphas_to_test[smallest_idx]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.29285714285714287"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rcv3.alpha_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x9ae06a0>]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    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VORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xb48cdd8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "plt.plot(alphas_to_test, rcv3.cv_values_.mean(axis=0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.metrics import mean_absolute_error\n",
    "\n",
    "from sklearn.metrics import make_scorer\n",
    "MAD_scorer = make_scorer(mean_absolute_error, greater_is_better=False)\n",
    "\n",
    "rcv4 = RidgeCV(alphas=alphas_to_test, store_cv_values=True, scoring=MAD_scorer)\n",
    "rcv4.fit(reg_data, reg_target)\n",
    "smallest_idx = rcv4.cv_values_.mean(axis=0).argmin()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.00070580517282746945"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rcv4.cv_values_.mean(axis=0)[smallest_idx]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "alphas_to_test[smallest_idx]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "X = np.linspace(0, 5)\n",
    "y_truth = 3 * X\n",
    "y_noise = np.random.normal(0, 0.5, len(y_truth)) #normally distributed noise with mean 0 and spread 0.1\n",
    "y_noisy = (y_truth + y_noise)\n",
    "\n",
    "\n",
    "from sklearn.linear_model import BayesianRidge\n",
    "br_inst = BayesianRidge().fit(X.reshape(-1, 1), y_noisy)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Container object of 3 artists>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaoAAAFCCAYAAACgmJkZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8VNX9//HXB0ggRkHQoIKSKFVZlEUFtS4kCrgrFVxQ\n65aqLGqrtV+s+quhttaltVVKXONWBVGxCgIuKKMgCIgsyqZVExUFRmURCBDI+f1x74RJMhMmMMlM\nJu/n45EHyZ0zd84ly2fOOZ/7OeacQ0REJFk1SXQHREREaqJAJSIiSU2BSkREkpoClYiIJDUFKhER\nSWoKVCIiktQUqCTuzOxEM1uaoNd+2Mxur+HxcjM7pB77c5CZrTczq6/XrKEvP5tZTg2Pf2Vmp9Rf\nj0Rio0CVAsys2Mw2+X8QfzSziWbWPlH9cc7NcM51rotzV7nW78zsKTPbI+y1hzrn/lpT9+qoX9PM\n7OpqL+bcN865li7ONyya2a1mNrnKsc/NbFKVY5+Z2YV+X/ZyzhX7x58ysz/vxutfYWbb/O/Dej8I\nrjez/Xf1nLvYj4CZlfqvvcb/+oj67IPUPQWq1OCAs5xzLYEDgNXAqMR2qc6EX2sPoCfwx1o8P+Ej\nmzh5Hzg+NFLzA0QzoGeVYx39tnVhph+EW/pBsKVzbmXVRmbWNJZjO2Nmkf5eOWCY//PQBngP+E9t\nz72rfZL6oUCVOgzAObcVeBnoUvGA2Zlm9rGZrTOzEjO7M+yx181seKUTmS00s/P8zzuZ2Vv+SG2p\nmV1Q5byL/Xez35jZzf7xPmb2TVi7EWb2P7/dp2Y2IOyxK8xsupndb2Y/mdkXZnZ6jNe6GngTL2CF\nzldppGBmf/BHXt+a2VWEjajMrI0/+lxnZrPN7C4zmx72eNRrj5WZZfvTjU38r6eZ2Z/NbIb///GG\nmbU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0yEDUZLZFTf6nwDmgu8Aszyzaz\ndOBiINWyj1L13WrIk8AS59yDie5IvJnZvqH6m/60Sj9gWWJ7FR/Ouduccx2cc4fg/d69m0pBysz2\n8Ef6mFkm0J8aCio0NM65VcA3ZnaYf+hUangDVd/p6QPM7BvgOOB1M5tSn68fb8657cD1wFvAYuAF\n51zUzJWGxszGADOBw8zsazO7KtF9iiczOwG4FDjFTwFOtT3VDgCmmdkCvLW3N51zkxPcJ4nNfsAM\nf33xQ7zydG8luE/xdiPwvP/z2R24O1pD3fArIiJJTVl/IiKS1BSoREQkqSlQiYhIUlOgEhGRpKZA\nJSIiSU2BSkREkpoClYiIJDUFKhERSWr/H17bR/+QnCO6AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x99970f0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "y_pred, y_err = br_inst.predict(X.reshape(-1, 1), return_std=True)\n",
    "\n",
    "plt.figure(figsize=(7, 5))\n",
    "plt.scatter(X, y_noisy)\n",
    "plt.title(\"Bayesian Ridge Line With Error Bars\")\n",
    "plt.errorbar(X, y_pred, y_err, color='green')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "y_pred, y_err = br_inst.predict(X.reshape(-1, 1), return_std=True)\n",
    "\n",
    "plt.figure(figsize=(7, 5))\n",
    "plt.scatter(X, y_noisy)\n",
    "plt.title(\"Bayesian Ridge Line With Error Bars\")\n",
    "plt.errorbar(X, y_pred, y_err, color='green')\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "As a final aside on BayesianRidge, you can perform hyper-parameter optimization on the parameters alpha_1, alpha_2, lambda_1, and lambda_2 using a cross-validated grid search.\n",
    "\n",
    "Using sparsity to regularize models\n",
    "\n",
    "The least absolute shrinkage and selection operator (LASSO) method is very similar to ridge regression and LARS. It's similar to Ridge Regression in the sense that we penalize our regression by some amount, and it's similar to LARS in that it can be used as a parameter selection, and it typically leads to a sparse vector of coefficients.\n",
    "\n",
    "Getting ready\n",
    "\n",
    "To be clear, lasso regression is not a panacea. There can be computation consequences to using lasso regression. As we'll see in this recipe, we'll use a loss function that isn't differential, and therefore, requires special, and more importantly, performance-impairing workarounds.\n",
    "\n",
    "How to do it...\n",
    "\n",
    "Let's go back to the trusty make_regression function and create a dataset with the same parameters:\n",
    "from sklearn.datasets import make_regression\n",
    "reg_data, reg_target = make_regression(n_samples=200, n_features=500, n_informative=5, noise=5)\n",
    "Next, we need to import the Lasso object:\n",
    "from sklearn.linear_model import Lasso\n",
    "lasso = Lasso()\n",
    "Lasso contains many parameters, but the most interesting parameter is alpha. It scales the penalization term of the Lasso method. For now, leave it as 1. As an aside, and much like ridge regression, if this term is 0, lasso is equivalent to linear regression:\n",
    "lasso.fit(reg_data, reg_target)\n",
    "Again, let's see how many of the coefficients remain nonzero:\n",
    "np.sum(lasso.coef_ != 0)\n",
    "7\n",
    "lasso_0 = Lasso(0)\n",
    "lasso_0.fit(reg_data, reg_target)\n",
    "np.sum(lasso_0.coef_ != 0)\n",
    "500\n",
    "None of our coefficients turn out to be 0, which is what we expect. Actually, if you run this, you might get a warning from scikit-learn that advises you to choose LinearRegression.\n",
    "\n",
    "How it works...\n",
    "\n",
    "Lasso cross-validation\n",
    "\n",
    "Choosing the most appropriate lambda is a critical problem. We can specify the lambda ourselves or use cross-validation to find the best choice given the data at hand:\n",
    "\n",
    "from sklearn.linear_model import LassoCV\n",
    "lassocv = LassoCV()\n",
    "lassocv.fit(reg_data, reg_target)\n",
    "lassocv will have, as an attribute, the most appropriate lambda. scikit-learn mostly uses alpha in its notation, but the literature uses lambda:\n",
    "\n",
    " lassocv.alpha_\n",
    "0.75182924196508782\n",
    "The number of coefficients can be accessed in the regular manner:\n",
    "\n",
    "lassocv.coef_[:5]\n",
    "array([-0., -0.,  0.,  0., -0.])\n",
    "Letting lassocv choose the appropriate best fit leaves us with 11 nonzero coefficients:\n",
    "\n",
    "np.sum(lassocv.coef_ != 0)\n",
    "15\n",
    "Lasso for feature selection\n",
    "\n",
    "Lasso can often be used for feature selection for other methods. For example, you might run lasso regression to get the appropriate number of features, and then use these features in another algorithm.\n",
    "\n",
    "To get the features we want, create a masking array based on the columns that aren't zero, and then filter to keep the features we want:\n",
    "\n",
    "\n",
    "mask = lassocv.coef_ != 0\n",
    "new_reg_data = reg_data[:, mask]\n",
    "new_reg_data.shape\n",
    "(200L, 15L)\n",
    "Taking a more fundame"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
